﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using iSun.BLL.Base;
using iSun.Entity;
using iSun.Common;

namespace iSun.BLL
{
    /// <summary>
    /// 职务管理业务处理类型
    /// </summary>
    public class BDutyInfo : BaseBussnies
    {
        /// <summary>
        /// 根据职务类型ID获取职务列表
        /// </summary>
        /// <param name="DutyId">职务类型ID</param>
        /// <returns></returns>
        public IList<V_DatDutyInfo> GetDutyInfoByDutyId(Guid DutyTypeId)
        {
            this.entity = new V_DatDutyInfo();
            this.Order = "SequenceNo";
            return GetEntitysByCondition<V_DatDutyInfo>("DutyTypeId='" + DutyTypeId + "'");
        }

        /// <summary>
        /// 根据职务类型名获取职务列表
        /// </summary>
        /// <param name="DutyName">职务类型名</param>
        /// <returns></returns>
        public IList<V_DatDutyInfo> GetDutyInfoByDutyName(string DutyTypeName)
        {
            this.entity = new V_DatDutyInfo();
            this.Order = "SequenceNo";
            return GetEntitysByCondition<V_DatDutyInfo>("DutyTypeName='" + DutyTypeName + "'");
        }
        /// <summary>
        /// 根据职务ID获取职务列表
        /// </summary>
        /// <param name="DutyInfoId">职务ID</param>
        /// <returns></returns>
        public IList<V_DatDutyInfo> GetDutyInfoById(Guid DutyInfoId)
        {
            this.entity = new V_DatDutyInfo();
            this.Order = "SequenceNo";
            return this.GetEntitysByCondition<V_DatDutyInfo>("ID='DutyInfoId'");
        }
        /// <summary>
        /// 根据职务ID获取职务列表
        /// </summary>
        /// <param name="DutyInfoId">职务ID</param>
        /// <returns></returns>
        public DatDutyInfo GetDatDutyInfoById(Guid DutyInfoId)
        {
            this.entity = new DatDutyInfo();
            return GetEntityByCondition("ID ='" + DutyInfoId + "'") as DatDutyInfo;
        }

        /// <summary>
        /// 判断职务名是否存在
        /// </summary>
        /// <returns></returns>
        public bool IsExistDutyInfoName(string Name)
        {
            this.entity = new DatDutyInfo();
            return GetEntityByCondition("Name='" + Name + "'") != null;
        }

        /// <summary>
        /// 修改时判断职务名称是否已存在
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Id"></param>
        /// <returns></returns>
        public bool IsExistDutyInfoName(string Name, Guid Id)
        {
            this.entity = new DatDutyInfo();
            return GetEntityByCondition("Name='" + Name + "' and ID<>'" + Id + "'") != null;
        }
    }
}
